﻿/*
Copyright © 2011 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See <license.txt> for the complete license of the software.
*/

namespace Simple.Storage
{
    /// <summary>
    /// Defines how a new data source is initialized by the engine.
    /// </summary>
    public interface IInitializer
    {
        /// <summary>
        /// Adds default serializers to a provided group.
        /// </summary>
        /// <param name="datasource">
        /// The initialized data source.
        /// </param>
        /// <param name="serializers">
        /// The serializers used for the properties of the <paramref name="datasource"/>.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// One of the parameters is <c>null</c>.
        /// </exception>
        void CreateSerializers(IDataSource datasource, IGroupedSerializer serializers);

        /// <summary>
        /// Creates a serializer used for the links with a specified persisted class.
        /// </summary>
        /// <param name="datasource">The initialized data source.</param>
        /// <param name="definition">The definition of the linked elements.</param>
        /// <param name="propertySerializer">The serializer used for properties.</param>
        /// <returns>The serializer used to serialize the links of the <paramref name="definition"/> class.</returns>
        ISerializer CreateLinkSerializer(IDataSource datasource, IClassDefinition definition, ISerializer propertySerializer);

        /// <summary>
        /// Creates a serializer used for the instance of a specified persisted class.
        /// </summary>
        /// <param name="datasource">The initialized data source.</param>
        /// <param name="definition">The definition of the serialized instances.</param>
        /// <param name="propertySerializer">The serializer used for properties.</param>
        /// <returns>The serializer used to serialize the instances of the <paramref name="definition"/> class.</returns>
        ISerializer CreateClassSerializer(IDataSource datasource, IClassDefinition definition, ISerializer propertySerializer);
    }
}
